using DesktopApp.ViewModels; // For RuleItemViewModel
using System.Collections.Generic;

namespace DesktopApp.ViewModels.Services
{
    /// <summary>
    /// Represents the calculated rule statistics.
    /// </summary>
    /// <param name="EnabledCount">Number of enabled rules.</param>
    /// <param name="TotalCount">Total number of rules.</param>
    public record RuleStats(int EnabledCount, int TotalCount);

    /// <summary>
    /// Defines the contract for calculating various statistics used in the application.
    /// </summary>
    public interface IStatisticsService
    {
        /// <summary>
        /// Calculates the number of lines in the given text.
        /// </summary>
        /// <param name="text">The text content.</param>
        /// <returns>The number of lines.</returns>
        int CalculateLineCount(string? text);

        /// <summary>
        /// Calculates the reduction rate based on original and result line counts.
        /// </summary>
        /// <param name="originalCount">The original line count.</param>
        /// <param name="resultCount">The result line count.</param>
        /// <returns>The reduction rate as a percentage (0-100), or null if original count is zero.</returns>
        double? CalculateReductionPercentage(int originalCount, int resultCount);

        /// <summary>
        /// Calculates the number of enabled and total rules.
        /// </summary>
        /// <param name="rules">The collection of rules.</param>
        /// <returns>A RuleStats record containing the counts.</returns>
        RuleStats CalculateRuleStats(IEnumerable<RuleItemViewModel> rules);

        /// <summary>
        /// Generates a summary string of enabled rule names.
        /// </summary>
        /// <param name="rules">The collection of rules.</param>
        /// <returns>A summary string (e.g., "已应用: Rule1, Rule2") or a default string if none are enabled.</returns>
        string GenerateAppliedRulesSummary(IEnumerable<RuleItemViewModel> rules);
    }
} 